<?php


namespace backend\flow_up;
use Yii;

class DataApi {

	/*
		上海常悦网络科技有限公司 提供流量充值接口
	 */
    public function changyue_api_blance() {
    	$app_id = 'gz9QqAh1y1';
    	$app_secret = 'OmurNEsADZdFBeZFUZlO';
    	$sign   =   MD5($app_id.$app_secret);
    	$url = 'http://112.124.59.189:8100/api/v1/account/queryblance.json?app_id=' . $app_id . '&verify_sign=' . $sign;
    	$return = file_get_contents($url);
	    $return = json_decode($return,true);
	    return $return;
	}

	public function changyue_api_submit() {
    	$app_id = 'gz9QqAh1y1';
    	$app_secret = 'OmurNEsADZdFBeZFUZlO';
    	$sign   =   MD5($app_id.$app_secret);
    	$url = 'http://112.124.59.189:8100/api/v1/order/submit.json?app_id=' . $app_id . '&verify_sign=' . $sign . '&phone_no=13101841234&flow_val=20&product_code=P10010-00-11-0&out_order_id=SH321321321123&timestamp=20160311154611122' ;
    	$return = file_get_contents($url);
	    $return = json_decode($return,true);
	    return $return;
	}
	public function changyue_api_order() {
    	$app_id = 'gz9QqAh1y1';
    	$app_secret = 'OmurNEsADZdFBeZFUZlO';
    	$sign   =   MD5($app_id.$app_secret);
    	$url = 'http://112.124.59.189:8100/api/v1/order/query.json' ;
    	// $return = file_get_contents($url);
	    // $return = json_decode($return,true);
	    // return $return;
	    $param = array(
					'app_id' => $app_id,
					'verify_sign' => $sign,
					'out_order_id' => 'SH321321321123');
	   	$json = json_encode($param);
	    $ch = curl_init();  
	    curl_setopt($ch, CURLOPT_POST, 1);  
	    curl_setopt($ch, CURLOPT_URL, $url);  
	    curl_setopt($ch, CURLOPT_POSTFIELDS, $param);  
	    curl_setopt($ch, CURLOPT_HTTPHEADER, array(  
	        'Content-Type: application/json; charset=utf-8',  
	        'Content-Length: ' . strlen($json))  
	    );  
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    $return = curl_exec($ch);  
	    $status = json_decode($return,true);
	    return $return;
	}
}
